package com.cheung.leetcode.contest.week.week403;

import org.junit.jupiter.api.Test;

import java.util.Arrays;

/**
 * @BelongsProject : java-leetcode
 * @BelongsPackage : com.cheung.leetcode.contest.week403
 * @Author :  cheungming
 * @CreateTime : 2024-06-24 16:31:06
 * @Description : 第一题
 * @Version : 1.0
 */
public class Code3194Test {

    public double minimumAverage(int[] nums) {
        Arrays.sort(nums);
        double min = Integer.MAX_VALUE;
        for (int i = 0; i < nums.length / 2; i++) {
            min = Math.min(min, (nums[i] + nums[nums.length - 1 - i]) / 2.0);
        }
        return min;
    }

    @Test
    public void test1() {
        assert minimumAverage(new int[]{7, 8, 3, 4, 15, 13, 4, 1}) == 5.5;
    }

    @Test
    public void test2() {
        assert minimumAverage(new int[]{1, 9, 8, 3, 10, 5}) == 5.5;
    }

    @Test
    public void test3() {
        assert minimumAverage(new int[]{1, 2, 3, 7, 8, 9}) == 5.0;
    }
}
